//
//  YblbVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2020/12/9.
//

import Foundation

extension YblbVC {
    
    func initUI() {
        
        let top_view = UIImageView.init(image: #imageLiteral(resourceName: "beijing2@1.5x"))
        top_view.isUserInteractionEnabled = true
        view.addSubview(top_view)
        top_view.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(UIDevice.lgf_NavBarH())
        }
        
        
        self.navTitle = ""
        self.lgf_NavigationBar.style.lgf_TitleColor = UIColor.white
        self.lgf_NavigationBar.lgf_line?.isHidden = true
        self.lgf_NavigationBar.lgf_Reload()
        
        if type == "标注" {
            let style = LGFSwiftPTStyle.init()
            style.lgf_Titles = ["样本列表", "医生列表"]
            style.lgf_LineWidthType = .fixedWith
            style.lgf_TitleFixedWidth = 80
            style.lgf_LineWidth = style.lgf_TitleFixedWidth
            style.lgf_LineHeight = 35
            style.lgf_LineColor = UIColor.white
            style.lgf_PVTitleViewBackgroundColor = UIColor.clear
            style.lgf_TitleSelectFont = UIFont.systemFont(ofSize: 16)
            style.lgf_UnTitleSelectFont = UIFont.systemFont(ofSize: 16)
            style.lgf_TitleSelectColor = UIColor.init(lgf_HexString: "0F88F2")
            style.lgf_UnTitleSelectColor = UIColor.init(lgf_HexString: "FFFFFF")
            style.lgf_TitleHaveAnimation = false
            
            
            let top_pt = LGFSwiftPT.lgf(style, self, self.lgf_NavigationBar.lgf_TitleView, nil)
            top_pt.layer.borderWidth = 1
            top_pt.layer.borderColor = UIColor.white.cgColor
            top_pt.layer.cornerRadius = 4
            top_pt.clipsToBounds = true
            top_pt.lgf_SwiftPTDelegate = self
            Timer.lgf_After(S: 0.1) {
                top_pt.snp.makeConstraints { (make) in
                    make.center.equalToSuperview()
                    make.width.equalTo(160)
                    make.height.equalTo(35)
                }
                top_pt.lgf_ReloadTitle()
            }
        } else {
            self.navTitle = "样本列表"
        }
        
        
        collectionView = UICollectionView.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout.lgf_Layout(0, 0, 8, 0, 0, 0))
        collectionView.backgroundColor = UIColor.init(lgf_HexString: "F1F2F4")
        collectionView.lgf_Register(cellType: YblbCell.self)
        collectionView.delegate = self
        collectionView.dataSource = self
        view.addSubview(collectionView)
        collectionView.snp.makeConstraints { (make) in
            make.top.equalTo(top_view.snp.bottom)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview()
            make.bottom.equalToSuperview()
        }
        
        if type == "标注" {
            collectionView2 = UICollectionView.init(frame: .zero, collectionViewLayout: UICollectionViewFlowLayout.lgf_Layout(0, 0, 8, 0, 0, 0))
            collectionView2.backgroundColor = UIColor.init(lgf_HexString: "F1F2F4")
            collectionView2.lgf_Register(cellType: Yblb2Cell.self)
            collectionView2.delegate = self
            collectionView2.dataSource = self
            view.addSubview(collectionView2)
            collectionView2.snp.makeConstraints { (make) in
                make.top.equalTo(top_view.snp.bottom)
                make.centerX.equalToSuperview()
                make.width.equalToSuperview()
                make.bottom.equalToSuperview()
            }
        }
        
    }
    
}

extension YblbVC: LGFSwiftPTDelegate {
    func lgf_SelectSwiftPTTitle(_ selectIndex: Int) {
        if selectIndex == 0 {
            collectionView.isHidden = false
            collectionView2.isHidden = true
        } else if selectIndex == 1 {
            collectionView.isHidden = true
            collectionView2.isHidden = false
        }
    }
}
